<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
	<div id="div" style="width: 200px;height: 200px; background-color: gray;">
    <a href="#" id="a">百度</a>
	</div>
</body>
<script>
   document.getElementById('a').onclick=function(e){
   	   console.log('a');
   	   //阻止默认事件
   	   e.preventDefault();
   	   //阻止冒泡事件
   	   e.stopPropagation();
   }
   
   document.getElementById('div').onclick=function(e){
   	   console.log('div');
   }




</script>
</html>